<template>
	<view class="container container17782">
		<view class="flex flex-wrap diygw-col-24 flex-direction-column flex1-clz">
			<diy-sticky offset-top="0">
					<view class="flex diy-sticky-100 flex-wrap diygw-col-24 flex-clz">
						<view class="diygw-col-0 orange text-clz"> 学号 </view>
						<view class="diygw-col-0 green text3-clz"> 姓名 </view>
						<view class="diygw-col-0 blue text2-clz"> 课程 </view>
						<view class="diygw-col-0 pink text1-clz"> 分数 </view>
						<view class="clearfix"></view>
					</view>
					<view class="clearfix"></view>
				</diy-sticky>
			<view v-for="(item,index) in printArray" class="flex flex-wrap diygw-col-24 flex7-clz " @click="jump_to(item.name)">
				<view class="diygw-col-0 text24-clz" > {{item.id}} </view>
				<view class="diygw-col-0 text30-clz"> {{item.name}} </view>
				<view class="diygw-col-0 text33-clz"> {{item.subject}} </view>
				<view class="diygw-col-0 text35-clz"> {{item.score}} </view>
			</view>
		</view>
		<view class="flex diygw-col-24 diygw-bottom olive bar-clz">
			<view class="diygw-grid diygw-actions">
				<button @tap="navigateTo" data-type="page" data-url="/pages/Home" class="diygw-action">
					<view class="diygw-grid-inner">
						<view class="diygw-grid-icon diygw-avatar diy-icon-home" style="color: #ffffff"> </view>
						<view class="diygw-grid-title"> 首页 </view>
					</view>
				</button>
				<button @tap="navigateTo" data-type="page" data-url="/pages/data" class="diygw-action addon">
					<view class="diygw-grid-inner">
						<view class="diygw-grid-icon diygw-avatar diy-icon-discover" style="color: #ffffff"> </view>
						<view class="diygw-grid-title"> 数据信息 </view>
					</view>
				</button>
				<button @tap="navigateTo" data-type="page" data-url="/pages/vip" class="diygw-action">
					<view class="diygw-grid-inner">
						<view class="diygw-grid-icon diygw-avatar diy-icon-people" style="color: #ffffff"> </view>
						<view class="diygw-grid-title"> 用户中心 </view>
					</view>
				</button>
			</view>
		</view>
		<view class="version text-grey flex-direction-column flex diygw-col-24 justify-center align-center">
			<view>  </view>
			<view> http://www.arise.com </view>
		</view>
		<view class="clearfix"></view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				//用户全局信息
				userInfo: {},
				//页面传参
				globalOption: {},
				//自定义全局变量
				globalData: {},
                //定义一个数组，用于存放数据信息
                printArray: [],
				//定义第几次请求变量
				pageindex:0,
				//定义是否到底
				isbottom:false,
			};
		},
		onShow() {
			this.setCurrentPage(this);
            this.get_data();
		},
		onLoad(option) {
			this.setCurrentPage(this);
			if (option) {
				this.setData({
					globalOption: this.getOption(option)
				});
			}

			this.init();
            
		},
		onReachBottom(){
				    // 触底的时候请求数据，即为上拉加载更多
					if(!this.isbottom){
						this.pageindex++
						this.get_data()
						//this.search()
					}
				    
				        console.log('已加载全部数据')
				   
				},
		methods: {
			async init() {},
            get_data(){
                uni.request({
                    url:'http://127.0.0.1:8080/api/demo/getlist',
                    method:'POST',
                    data:{
						pageindex:this.pageindex,
						num:20
                    }
                }).then((res)=>{
                    console.log(res);
                    if (res.data.code==1){
                        this.printArray=[...this.printArray,...res.data.data]
                    }
					if(res.data.data.length<20){
						this.isbottom=true
					}
                })
            },
            jump_to(name){
                uni.navigateTo({
                    url:'/pages/details?name='+name,
                    
                })
            }
		}
	};
</script>

<style lang="scss" scoped>
	.flex1-clz {
		margin-left: 5px;
		z-index: 1000;
		width: calc(100% - 5px - 5px) !important;
		margin-top: 5px;
		margin-bottom: 5px;
		margin-right: 5px;
	}
	.flex-clz {
		z-index: 1000;
	}
	.text-clz {
		padding-top: 8px;
		border-bottom-left-radius: 0px;
		overflow: hidden;
		flex: 1;
		padding-left: 8px;
		padding-bottom: 8px;
		border-top-left-radius: 6px;
		border-top-right-radius: 6px;
		border-bottom-right-radius: 0px;
		text-align: center;
		padding-right: 8px;
	}
	.text3-clz {
		padding-top: 8px;
		border-bottom-left-radius: 0px;
		overflow: hidden;
		flex: 1;
		padding-left: 8px;
		padding-bottom: 8px;
		border-top-left-radius: 6px;
		border-top-right-radius: 6px;
		border-bottom-right-radius: 0px;
		text-align: center;
		padding-right: 8px;
	}
	.text2-clz {
		padding-top: 8px;
		border-bottom-left-radius: 0px;
		overflow: hidden;
		flex: 1;
		padding-left: 8px;
		padding-bottom: 8px;
		border-top-left-radius: 6px;
		border-top-right-radius: 6px;
		border-bottom-right-radius: 0px;
		text-align: center;
		padding-right: 8px;
	}
	.text1-clz {
		padding-top: 8px;
		border-bottom-left-radius: 0px;
		overflow: hidden;
		flex: 1;
		padding-left: 8px;
		padding-bottom: 8px;
		border-top-left-radius: 6px;
		border-top-right-radius: 6px;
		border-bottom-right-radius: 0px;
		text-align: center;
		padding-right: 8px;
	}
	.flex7-clz {
		background-color: rgba(220, 220, 220, 0.68);
		z-index: 1000;
	}
	.text24-clz {
		padding-top: 8px;
		flex: 1;
		padding-left: 0px;
		padding-bottom: 8px;
		text-align: center;
		padding-right: 0px;
	}
	.text30-clz {
		padding-top: 8px;
		flex: 1;
		padding-left: 0px;
		padding-bottom: 8px;
		text-align: center;
		padding-right: 0px;
	}
	.text33-clz {
		padding-top: 8px;
		flex: 1;
		padding-left: 0px;
		padding-bottom: 8px;
		text-align: center;
		padding-right: 0px;
	}
	.text35-clz {
		padding-top: 8px;
		flex: 1;
		padding-left: 0px;
		padding-bottom: 8px;
		text-align: center;
		padding-right: 0px;
	}
	.bar-clz {
		color: #fefefe;
	}
	.container17782 {
		padding-left: 0px;
		padding-right: 0px;

		font-size: 12px;
	}
	.container17782 {
		padding-bottom: 80px;
	}
</style>
